package game.page.common;

import java.io.IOException;

/**
 * Some help method for xhtml page code.
 * 
 * @author Linzy
 * Create Date: 2010 1 17 02:10:16
 */
public class XHtmlUtils {

	/**
	 * Write a line separator.
	 * 
	 * @param sb
	 */
	public static void line(Appendable sb) {
		try {
			sb.append("<br/>");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Start a form.
	 * 
	 * @param sb
	 * @param actionUrl
	 */
	public static void formStart(Appendable sb, String actionUrl) {
		try {
			sb.append("<form method=\"post\" action=\"");
			sb.append(actionUrl);
			sb.append("\">");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	/**
	 * Wrtite a form input.
	 * 
	 * @param sb
	 * @param inputName
	 * @param value
	 */
	public static void inputText(Appendable sb, String inputName, String value) {
		try {
			sb.append("<input type=\"text\" ");
			sb.append("name=\"" +inputName + "\" ");
			sb.append("value=\"" + value + "\" />");
		} catch (IOException e) {
			e.printStackTrace();
		}
	} // inputText()

	/**
	 * End a form.
	 * 
	 * @param sb
	 * @param submitVal
	 */
	public static void formEnd(Appendable sb, String submitVal) {
		try {
			sb.append("<input type=\"submit\" ");
			sb.append("value=\"" + submitVal + "\" />");
			sb.append("</form>");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	} // formEnd()

	
	
} // end of class
